package com.ruoyi.tzzl.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.tzzl.domain.WzCertification;
import com.ruoyi.tzzl.domain.vo.QueryVo;
import com.ruoyi.tzzl.mapper.WzCertificationMapper;
import com.ruoyi.tzzl.service.IWzCertificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户认证Service业务层处理
 * @author by caoyong
 * @date 2022/11/17
 **/
@Service
public class WzCertificationServiceImpl extends ServiceImpl<WzCertificationMapper, WzCertification> implements IWzCertificationService {

    @Autowired
    WzCertificationMapper wzCertificationMapper;

    /**
     * 查询用户认证列表
     */
    @Override
    public List<WzCertification> selectWzCertificationList(QueryVo queryVo) {
        return wzCertificationMapper.selectWzCertificationList(queryVo);
    }

    /**
     * 查询用户认证资料
     * */
    @Override
    public List<WzCertification> getByWid(Long id) {
        LambdaQueryWrapper<WzCertification> lqw =new LambdaQueryWrapper<>();
        lqw.eq(WzCertification::getWid,id);
        return this.list(lqw);
    }

    /**
     * 查询用户是否实名认证
     * return 0-未认证 1-已认证
     *
     * @param id
     */
    @Override
    public String getIfAuthentication(Long id) {
        LambdaQueryWrapper<WzCertification> lqw =new LambdaQueryWrapper<>();
        lqw.eq(WzCertification::getWid,id);
        lqw.in(WzCertification::getCertificationState,"1","2");
        lqw.eq(WzCertification::getCertificationType,"1");
       WzCertification wzCertification = this.getOne(lqw);
       if (ObjectUtils.isNotEmpty(wzCertification)){
           return "1";
       }else {
           return "0";
       }
    }


}
